<?php

/**
 * 推送消息抽象基类
 *
 * PushFactory.class.php
 * @copyright			copyright(c) 2016 - 2017
 * @author				myy
 * @date				2017-7-25
 */
namespace app\common\com\push;

abstract class PushBase {

    //推送应用唯一标识
    protected $_appId;

    //推送消息通道用户密钥
	protected $_masterSecret;

    //推送消息通道app密钥
	protected $_appKey;

    //host
	protected $_host;

    //错误信息
	protected $error = '';
	
	public function __construct($config) {
		$this->_masterSecret   = $config['masterSecret'];
		$this->_appKey         = $config['appKey'];
		$this->_host           = $config['host'];
		$this->_appId          = $config['appId'];
	}

	/**
	 * 获取错误信息
	 * 
	 * @return string
	 */
	public function getError() {
		return $this->error;
	}

    /**
     * 发送消息给指定的单个用户
     *
     * @param $user_id
     * @param string $title 标题
     * @param string $content 内容
     * @param string $page 要跳转的页面
     * @param string $params 携带的参数
     * @return mixed
     */
	abstract public function sendToOne($user_id, $title, $content, $page = '', $params = '');

    /**
     * 发送消息给指定的用户列表
     * @param $user_list
     * @param $title
     * @param $content
     * @return mixed
     */
	abstract public function sendToList(array $user_list, $title, $content);


}